<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>组件模板-分离写法</title>
    <script src="../lib/vue_v2.6.14.js"></script>
  </head>
  <body>
    <div id="app">
      <my-cpn></my-cpn>
    </div>

    <!-- 分离写法1 -->
    <!-- <template id="cpn">
      <div>
        <h2>{{ title }}</h2>
        <p>我是内容，哈哈哈哈</p>
      </div>
    </template> -->

    <!-- 分离写法2 -->
    <script type="text/x-template" id="cpn">
      <div>
        <h2>{{ title }}</h2>
        <p>我是内容，呵呵呵呵</p>
      </div>
    </script>

    <script>
      const vm = new Vue({
        el: '#app',
        data: {},
        components: {
          'my-cpn': {
            template: '#cpn',
            data() {
              return {
                title: '组件模板-分离写法'
              }
            }
          }
        }
      })
    </script>
  </body>
</html>
